package com.sztz.mapstruct.P映射倒置;

import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * CarMapper
 *
 * @author yyf
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {

    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);

    /**
     * 简单转换
     *
     * @param car
     * @return CarDto
     */
    @Mapping(source = "name", target = "carName")
    CarDTO toDto(Car car);


    /**
     * 倒置 toDto的Mapping信息
     * 若有多个映射需指定name
     *
     * @param carDTO
     * @return Car
     */
    @InheritInverseConfiguration
    Car toDto(CarDTO carDTO);
}
